// EtyMain.c

#include <stdio.h>
#include <stdlib.h>
#include "PkgUser.pb-c.h"

int main() {
	printf("A test for converting proto to json.\n");

	PkgUser__PhtListRespond tRpd;
	pkg_user__pht_list__respond__init(&tRpd);
	tRpd.code = 0x3001;
	tRpd.command = "Usr_Pht_List";
	tRpd.result = "0";
	tRpd.message = "成功";
	PkgUser__PhtListItem* oItm = malloc(sizeof(PkgUser__PhtListItem));
	pkg_user__pht_list__item__init(oItm);
	oItm->pht_idntifr = "1";
	oItm->pht_status = "1";
	oItm->url_finalztion = "https://www.baidu.com/1.jpg";

	tRpd.n_list = 1;
	tRpd.list = &oItm;

	unsigned char aBfr[1024] = { 0 };
	int nBlk = pkg_user__pht_list__respond__get_packed_size(&tRpd);
	nBlk = pkg_user__pht_list__respond__pack(&tRpd, aBfr);
#if 0
	FILE* hFle = fopen("d:\\1.dat", "w+b");
	fwrite(aBfr, 1, nBlk, hFle);
	fclose(hFle);
#endif
	free(oItm);
}
